/**
 * 
 */
package org.t2.backstage.module.gameserver.vo;

import java.time.LocalDateTime;

import org.gaming.tool.LocalDateTimeUtil;
import org.t2.backstage.module.gameserver.model.GameServer;
import org.t2.backstage.module.gameserver.model.GameServerRuntime;

/**
 * @author YY
 *
 */
public class GameServerDetailVo {
	private int id;
	private long platformId;
	private String platformName;
	private int serverId;
	private String name;
	private String socketType;
	private String externalIp;
	private String internalIp;
	private int tcpPort;
	private int httpPort;
	private String dbGameName;
	private String dbLogName;
	private boolean hide;
	private int status;
	private boolean recommend;
	private long openTime;
	private long realOpenTime;
	private int sendOpenStatus;
	private boolean opening;
	private int serverType;
	//运行时的参数
	private boolean running;
	private long heartTime;
	private int registerNum;
	private int createNum;
	private int onlineNum;
	private int battleNum;
	private int currBattleNum;
	private String maxMemory;
	private String freeMemory;
	private String totalMemory;
	private String leftMemory;
	private String usedMemory;
	
	public GameServerDetailVo() {
	}
	
	public GameServerDetailVo(GameServer gameServer, GameServerRuntime runtime) {
		this.id = gameServer.getId();
		this.serverId = gameServer.getServerId();
		this.name = gameServer.getName();
		this.platformId = gameServer.getPlatformId();
		this.platformName = gameServer.getPlatformName();
		this.socketType = gameServer.getSocketType();
		this.externalIp = gameServer.getExternalIp();
		this.internalIp = gameServer.getInternalIp();
		this.tcpPort = gameServer.getTcpPort();
		this.httpPort = gameServer.getHttpPort();
		this.dbGameName = gameServer.getDbGameName();
		this.dbLogName = gameServer.getDbLogName();
		this.status = gameServer.getStatus();
		this.recommend = gameServer.isRecommend();
		this.openTime = LocalDateTimeUtil.toEpochMilli(gameServer.getOpenTime());
		this.realOpenTime = LocalDateTimeUtil.toEpochMilli(gameServer.getRealOpenTime());
		this.sendOpenStatus = gameServer.getSendOpenStatus();
		this.opening = LocalDateTime.now().isAfter(gameServer.getRealOpenTime());
		this.serverType = gameServer.getServerType();
		this.hide = gameServer.isHide();
		
		if(runtime != null) {
			this.running = runtime.isRunning();
			this.heartTime = LocalDateTimeUtil.toEpochMilli(runtime.getHeartTime());
			this.registerNum = runtime.getRegisterNum();
			this.createNum = runtime.getCreateNum();
			this.onlineNum = runtime.getOnlineNum();
			this.battleNum = runtime.getBattleNum();
			this.currBattleNum = runtime.getCurrBattleNum();
			this.maxMemory = runtime.getMaxMemory();
			this.freeMemory = runtime.getFreeMemory();
			this.totalMemory = runtime.getTotalMemory();
			this.leftMemory = runtime.getLeftMemory();
			this.usedMemory = runtime.getUsedMemory();
		}
	}
	
	public GameServerDetailVo(GameServer gameServer) {
		this(gameServer, null);
	}
	
	public int getServerId() {
		return serverId;
	}

	public int getId() {
		return id;
	}

	public long getPlatformId() {
		return platformId;
	}

	public String getPlatformName() {
		return platformName;
	}

	public String getName() {
		return name;
	}

	public String getSocketType() {
		return socketType;
	}

	public String getExternalIp() {
		return externalIp;
	}

	public String getInternalIp() {
		return internalIp;
	}

	public int getTcpPort() {
		return tcpPort;
	}

	public int getHttpPort() {
		return httpPort;
	}

	public String getDbGameName() {
		return dbGameName;
	}

	public String getDbLogName() {
		return dbLogName;
	}

	public boolean isHide() {
		return hide;
	}

	public int getStatus() {
		return status;
	}

	public boolean isRecommend() {
		return recommend;
	}

	public long getOpenTime() {
		return openTime;
	}

	public long getRealOpenTime() {
		return realOpenTime;
	}

	public int getSendOpenStatus() {
		return sendOpenStatus;
	}

	public boolean isOpening() {
		return opening;
	}

	public int getServerType() {
		return serverType;
	}

	public boolean isRunning() {
		return running;
	}


	public int getRegisterNum() {
		return registerNum;
	}

	public int getCreateNum() {
		return createNum;
	}

	public int getOnlineNum() {
		return onlineNum;
	}

	public int getBattleNum() {
		return battleNum;
	}

	public int getCurrBattleNum() {
		return currBattleNum;
	}

	public String getMaxMemory() {
		return maxMemory;
	}

	public String getFreeMemory() {
		return freeMemory;
	}

	public String getTotalMemory() {
		return totalMemory;
	}

	public String getLeftMemory() {
		return leftMemory;
	}

	public String getUsedMemory() {
		return usedMemory;
	}

	public long getHeartTime() {
		return heartTime;
	}
	
}
